#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "../umlcore/BaseElement.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Comment;

/// <summary>
/// Element
/// An Element is a constituent of a model. As such, it has the capability of owning
/// other Elements.
/// </summary>
class UMLMODEL_EXPORT Element : public BaseElement {

public: // Constructors and destructors
    explicit Element(const QString& umlType="uml::Element");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Methods
    /// <summary>
    /// allOwnedElements
    /// The query allOwnedElements() gives all of the direct and indirect ownedElements
    /// of an Element.
    /// </summary>
    virtual shared_ptr<vector<Element>> allOwnedElements() const;

    /// <summary>
    /// mustBeOwned
    /// The query mustBeOwned() indicates whether Elements of this type must have an
    /// owner. Subclasses of Element that do not require an owner must override this
    /// operation.
    /// </summary>
    virtual bool mustBeOwned() const;

public: // Properties
    /// <summary>
    /// ownedComments getter
    /// The Comments owned by this Element.
    /// </summary>
    vector<shared_ptr<Comment>>& ownedComments();

    /// <summary>
    /// ownedElements getter
    /// The Elements owned by this Element.
    /// </summary>
    vector<shared_ptr<Element>>& ownedElements();

    /// <summary>
    /// owner getter
    /// The Element that owns this Element.
    /// </summary>
    shared_ptr<Element> owner() const;

    /// <summary>
    /// owner setter
    /// The Element that owns this Element.
    /// </summary>
    void setOwner(shared_ptr<Element> value);

private: // Fields
    /// <summary>
    /// ownedComments
    /// The Comments owned by this Element.
    /// </summary>
    vector<shared_ptr<Comment>> ownedComments_;

    /// <summary>
    /// ownedElements
    /// The Elements owned by this Element.
    /// </summary>
    vector<shared_ptr<Element>> ownedElements_;

    /// <summary>
    /// owner
    /// The Element that owns this Element.
    /// </summary>
    shared_ptr<Element> owner_;

};

} // namespace uml
